/**
 *
 */
package jp.seraph.same.core;

import jp.seraph.jsade.action.AgentAction;
import jp.seraph.jsade.core.World;
import jp.seraph.jsade.task.AgentTask;
import jp.seraph.jsade.task.TaskSelector;
import jp.seraph.jsmf.motion.Motion;

/**
 *
 *
 */
public class EditorMotionSelector implements TaskSelector {
    public Motion mMotion;
    public AgentAction mAction;
    public AgentAction mPermanentAction;

    /**
     *
     * @see jp.seraph.jsmf.motion.MotionSelector#getAgentAction(jp.seraph.jsade.core.World)
     */
    public AgentAction getAgentAction(World aWorld) {
        if(mPermanentAction != null)
            return mPermanentAction;

        AgentAction tAction = mAction;
        mAction = null;
        return tAction;
    }

    /**
     *
     * @see jp.seraph.jsmf.motion.MotionSelector#notifyMotionFinished()
     */
    public void notifyMotionFinished() {
    }

    /**
     *
     * @see jp.seraph.jsmf.motion.MotionSelector#selectMotion(jp.seraph.jsade.core.World)
     */
    public Motion selectMotion(World aWorld) {
        Motion tMotion = mMotion;
        mMotion = null;
        return tMotion;
    }

    /**
     *
     * @see jp.seraph.jsade.task.TaskSelector#selectTask(jp.seraph.jsade.core.World)
     */
    public AgentTask selectTask(World aWorld) {
        Motion tMotion = mMotion;
        mMotion = null;

        if(tMotion == null)
            return null;
        else
            return tMotion.toTask();
    }

    public void setMotion(Motion aMotion){
        mMotion = aMotion;
    }

    public void setAction(AgentAction aAction){
        mAction = aAction;
    }

    public void setPermanentAction(AgentAction aAction){
        mPermanentAction = aAction;
    }
}
